package com.xinchengxd.user.mapper;
import com.xinchengxd.user.entity.User;
import org.apache.ibatis.annotations.Insert;
import org.apache.ibatis.annotations.Select;
import org.apache.ibatis.annotations.Update;

public interface UserMapper {
    @Insert("insert into " +
            "mall_user(account,password,nickname,email,regtime,point,appid,openid)" +
            "values(#{account},#{password},#{nickname},#{email},#{regTime},#{point},#{appid},#{openid})")
    int add(User user);

    @Select("select id,account,nickname from mall_user where account = #{account} and password = #{password}")
    User sign(User user);

    @Select("select * from mall_user where id = #{id}")
    User look(Integer id);

    @Update("update mall_user set account=#{account},password=#{password}," +
            "nickname=#{nickname},email=#{email}" +
            "where id = #{id}")
    void update(User user);

    @Update("update mall_user set password=#{newPwd} where id = #{id}")
    void updateForPassword(String newPwd, Integer id);

    @Update("update mall_user set point=#{change} where id = #{id}")
    int changePoint(Integer id, Integer change);
}
